package com.ds.cluster;

import com.ds.common.ConfigCode;
import com.ds.common.util.ClassUtility;
import com.ds.server.JDSServer;


public class ClusterMananerFactory {



    private final static String defaultManagerClassName = "com.ds.web.client.WebClusterManagerImpl";

    public static ClusterMananer getClusterManager(ConfigCode code) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        ClusterMananer manager = null;
        String className  = JDSServer.getClusterClient().getServerNodeListByConfigCode(code).getClusterManagerClass();

        if (className != null && !className.equals("")) {
            manager = (ClusterMananer) ClassUtility.loadClass(className).newInstance();
        } else {
            manager = (ClusterMananer) ClassUtility.loadClass(defaultManagerClassName).newInstance();
        }
        return manager;
    }



}
